<?php 
/**
 * 删除头像，如果有的头像不符合审核要求，后台可以调用接口删除图片
 */
class DeleteAvaterImage extends APIBase {

	public $tag = "DeleteAvaterImage";

	public function before() {
		$this->initMysql();
		return true;
	}

	public function logic() {
		//删除前面的图片资源
		$old_avater_url = $this->data_redis->hget("hu:{$this->uid}","avater_url");
		$substr = strstr($old_avater_url,"zjhapi/image");
		if ($substr)
		{
			$old_res_pathfile = $_SERVER['DOCUMENT_ROOT']. "/" . $substr;
			if (file_exists($old_res_pathfile)) {
				$result = unlink($old_res_pathfile);
				if ($result) $this->e("delete $old_res_pathfile error");
			}
		}
		//设置新的图片url为空
		$this->data_redis->hset("hu:{$this->uid}","avater_url","");
		$this->mysql->update("player",array("avater_url" => ""), array('id'=>$this->uid));
		$this->returnData($data);
	}

	public function after() {
		$this->deinitDataRedis();
		$this->deinitMysql();
	}
}
?>


?>